//@/common/map

import AMapLoader from "@amap/amap-jsapi-loader";
export async function initMap(idName: string) {
  const AMap0 = await AMapLoader.load({
    key: "9e2366bc9fe947e6638ccad9188162e6", // 申请好的Web端开发者Key，首次调用 load 时必填
    version: "2.0", // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
    plugins: [
      "AMap.AutoComplete",
      "AMap.PlaceSearch",
      "AMap.PolygonEditor",
      "AMap.Geocoder",
      "AMap.Marker",
    ], // 需要使用的的插件列表，如比例尺'AMap.Scale'
  });
  const AMap = AMap0;
  const map = new AMap.Map(idName, {
    //设置地图容器id
    viewMode: "3D", //是否为3D地图模式
    center: [116.407162, 39.887269], // 初始化地图中心点[x,y]
    zoom: 4,
    resizeEnable: true,
  });
  return { AMap, map };
}
